package cn.chencaiju.App;

import java.util.Vector;

// 我的英雄坦克
class Hero extends Tank {
//	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    // 子弹

    Vector<Shot> bullet = new Vector<Shot>();
    Shot s = null;

    public Hero(int x, int y) {
        super(x, y);
    }

    // 开火
    public void shotEnemy() {

        switch (Direct) {
        case 0:
            // 创建一颗子弹
            s = new Shot(x + 8, y - 4, 0);
            // 把子弹加入向量
            bullet.add(s);
            break;
        case 1:
            s = new Shot(x + 9, y + 32, 1);
            bullet.add(s);
            break;
        case 2:
            s = new Shot(x - 8, y + 8, 2);
            bullet.add(s);
            break;
        case 3:
            s = new Shot(x + 32, y + 9, 3);
            bullet.add(s);
            break;
        default:
            break;
        }
        Thread t = new Thread(s);
        t.start();
    }

    public void moveUp() {
    	if((y-speed)>0)
    		y -= speed;
    }

    public void moveDown() {
    	if((y+speed)<=(MyPanel.backgroundheight-25))
    		y += speed;
    }

    public void moveLeft() {
    	if((x-speed)>0)
    		x -= speed;
    }

    public void moveRight() {
    	if((x+speed)<=(MyPanel.backgroundwidth-25))
    		x += speed;
    }
}